<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

<%--树形表格--%>
<table id="myDatagridaudio" style="width:600px;height:400px"></table>
<%--树形表格--%>

<!-- 添加对话框 -->
<div id="myAddDialogDivaudio" class="easyui-dialog" data-options="closed:true, width: 600, height: 400" >
    <form method="post" id="myFormaudio" enctype="multipart/form-data">
        <input type="hidden" name="albumId" id="albumAudioId"/>
        音频标题：<input type="text" name="audioName"/><br/><br/>
        选择音频文件：<input type="file" name="audio"/><br/><br/>
        音频的大小：<input type="text" name="audioSize"/><br/><br/>
        音频的序号：<input type="text" name="audioOrder"/><br/><br/><br/><br/>
        <input type="button" value="添加" onclick="doAddSubmit()">
    </form>
</div>
<!-- 添加对话框===END=== -->

<script type="text/javascript">
    $(function (){

        $('#myDatagridaudio').treegrid({
            url:'${pageContext.request.contextPath}/audio/showAll',
            idField:'id',
            treeField:'name',
            singleSelect : false,
            columns:[[
                {field:'name',title:'音频标题',width:180},
                {field:'audioOrder',title:'音频序号',width:60,align:'right'},
                {field:'audioSize',title:'音频大小',width:80}
            ]],
            onDblClickRow:function (row){
                if(row.audioOrder==null ){
                    $('#myAddDialogDivaudio').dialog("open");

                    $("#albumAudioId").val(row.id);
                }
            }
        });
    });

    function doAddSubmit(){

        $('#myFormaudio').form('submit', {
            url:"${pageContext.request.contextPath}/audio/add",
            success:function(data){
                var data=JSON.parse(data);
                if(data.flag){
                    $('#myAddDialogDivaudio').dialog("close");
                    $("#myDatagridaudio").treegrid("reload");
                }else{
                    $.messager.alert('提示框','添加失败，请确认！','warning');
                }
            }
        });
    }
    /* 添加音频 */

</script>